package com.lagou.sqlSession;

import com.lagou.config.XmlConfigBuilder;
import com.lagou.pojo.Configuration;

import java.io.InputStream;

/**
 * @author buddy
 * @date 2021/8/25
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream in) {
        // 1. 使用 dom4j 解析配置文件，将解析出来的内容封装到 Configuration 中
        XmlConfigBuilder builder = new XmlConfigBuilder();
        Configuration configuration = builder.parseConfig(in);

        // 2. 创建 SqlSessionFactory 对象：工厂类，生产 sqlSession 会话对象
        return new DefaultSqlSessionFactory(configuration);
    }
}
